package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCServiceRecord;
import com.shrct.businessprocess.customerservice.RCServiceRecordCriteria;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCEnterprise;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class RCServiceRecordCriteriaImpl extends HQLBasedPagedQueryCriteria<RCServiceRecord> implements RCServiceRecordCriteria {
  private String sid;
  
  public String getSid() {
    return this.sid;
  }
  
  public RCServiceRecordCriteria setSid(final String sid) {
    this.sid = sid;
    return this;			
    
  }
  
  private RCEnterprise customer;
  
  public RCEnterprise getCustomer() {
    return this.customer;
  }
  
  public RCServiceRecordCriteria setCustomer(final RCEnterprise customer) {
    this.customer = customer;
    return this;			
    
  }
  
  private RCEmployee worker;
  
  public RCEmployee getWorker() {
    return this.worker;
  }
  
  public RCServiceRecordCriteria setWorker(final RCEmployee worker) {
    this.worker = worker;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCServiceRecordImpl this  left join  this.workers as worker ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid()) ){
    	hql += " and (this.sid  LIKE :sid)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer()) ){
    	hql += " and ((this.customer) = (:customer))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getWorker()) ){
    	hql += " and ((worker) = (:worker))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid())){
    	query.setParameter("sid",getSid()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer())){
    	query.setParameter("customer",getCustomer()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getWorker())){
    	query.setParameter("worker",getWorker()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return true;
  }
  
  public RCServiceRecordCriteriaImpl() {
    initOrderBys();
  }
}
